#include <stdio.h>
#include <string.h>

int count_chinese_characters(const char *text) {
    int count = 0;
    int i = 0;
    int len = strlen(text);
    while (i < len) {
        unsigned char c1 = (unsigned char)text[i];
        if (c1 >= 0x81 && c1 <= 0xFE) {
            if (i + 1 < len) {
                unsigned char c2 = (unsigned char)text[i + 1];
                if ((c2 >= 0x40 && c2 <= 0xFE) && c2 != 0x7F) {
                    count++;
                    i += 2;
                    continue;
                }
            }
        }
        i++;
    }
    return count;
}

int main() {
    int n;
    if (scanf("%d", &n) != 1) {
        return 1;
    }
    getchar(); // 吸收换行符

    for (int i = 0; i < n; i++) {
        char text[100000]; // 假设每行文本不超过100000个字符
        if (fgets(text, sizeof(text), stdin) == NULL) {
            break;
        }
        // 去除可能的换行符
        size_t len = strlen(text);
        if (len > 0 && text[len - 1] == '\n') {
            text[len - 1] = '\0';
        }
        int chinese_count = count_chinese_characters(text);
        printf("%d\n", chinese_count);
    }
    return 0;
}